<script type="text/javascript" >
    jQuery(document).ready(function(){
        jQuery('.stExtra').remove();
        jQuery("#tabs ul li").each(function(){
        if(jQuery(this).children().attr('action') == 'gallery_app' || jQuery(this).children().attr('action') == 'coupon')
            jQuery(this).hide();
        if(jQuery(this).children().attr('action') == 'home_applications')
            jQuery(this).attr('class','current');
        });
        <?php
            if($action == 'coupon'){
                if($check == '' && $cur_page == 1){
                    echo "stFacebookToolbox.loadPage('coupon&check=1');";
                }
             }
        ?>
    });
    stFacebookToolbox.load_tooltip();
    stFacebookToolboxcustom.on_submitform_new('#template_upload');
    stFacebookToolbox.loadUploadButton('200');
    stFacebookToolbox.loadRemoveButton();
    stFacebookToolbox.sortColumn();
    stFacebookToolbox.shortAction();
        jQuery("a[rel^='prettyPhoto']").prettyPhoto({
            theme:'facebook',
            default_height:100,
            keyboard_shortcuts: false
        });

</script>
<style>

</style>

<div class="w100p bgl" id="stcontainer">
    <div class="w100p bgr p5b" id="result">
        <?php if(intval($user_id) == 0){?>
        <ul class="postcardAction" style="margin-left: 10px;padding-top: 15px;">
                
            <li>
                <select name="campains" onchange="stFacebookToolbox.loadPage('coupon&campaign='+this.value);">
                    <option value="all">All</option>
                    <?php foreach($campaign as $row){
                        $selected = '';
                        if($campaign_select == $row->CouponTemplateID)
                                $selected = 'selected';
                        echo "<option value='".$row->CouponTemplateID."' $selected>$row->CouponTemplateName</option>";
                    }?>
                </select>
            </li>
            </ul>
        <?php }?>
  
<table class="widefat" cellspacing="0">
                <thead>
                    <tr>
                        <?php print_column_headers('stFacebookToolbox_stFacebookToolbox'); ?>
                    </tr>
                </thead>

                <tbody>
                <?php
                if (count($results) > 0) {
                    
                    $tr_class = "";
                    $upload_data = wp_upload_dir();
                    foreach ($results as $result) {
                        $array = explode('-',substr($result->CouponGeneratedDateTime,0,10));
                        
                        $datetime = $array[2].'.'.$array[1].'.'.$array[0].' '.substr($result->CouponGeneratedDateTime,11);
                       // $description  = (strlen($result->CouponTemplateDescription) > 35)?substr($result->CouponTemplateDescription,0,35).'...':$result->CouponTemplateDescription;
                        if( empty($tr_class) || $tr_class == "class='bg_gray2'"){
                            $tr_class = "class='bg_gray1'";
                        }else{
                            $tr_class = "class='bg_gray2'";
                        }
                        echo "<tr id='$result->CouponID' $tr_class >"
                        . "<td>" . $model->getuser($result->CouponUserID)
                        . "<div class=\"row-actions short_action\">"
                        . "<span  short_action='' id='' action='' class='edit'  onclick='window.open(\"http://www.facebook.com/profile.php?id={$model->getFacebook($result->CouponUserID)}\");'>Facebook profile</span> | "
                        . "<span class='trash' short_action='delete' id='$result->CouponID' confirm='Are you sure you want to delete this coupon ?' style='cursor:pointer;'>Trash </span>"
                        . "</div>"
                        . "</td>"
                        . "<td>"
                        . $datetime
                        . "</td>"
                        . "<td>{$model->gettemplate($result->CouponTemplateID)}"
                        . "</td>"
                        . "<td>";
                        if($result->QCCodePath != '')
                        echo "<a rel='prettyPhoto' href='$result->QCCodePath' title=''><img src='$result->QCCodePath' width='70' title='' /></a>";
                        echo  "</td>"
                        . "<td><a href='{$result->GeneratedCouponPath}' target='_blank'>Download PDF</a>"
                        . "</td>"
                          . "</td>"
                        . "</td>"
                        
                        . "</tr>"
                        ;
                    }
                }
                ?>
                </tbody>
            </table>
            <div class="page_d">
                <?php echo $pagination?>
                <div class="cl"></div>
            </div>
    </div>
</div>